"""
@Project:Python crawler
@File:imgfile.py
@Author:邓建祥
@Date:10:57
"""
import os
import requests

url = "https://st-cn.meishij.net/r/208/102/1025708/s1025708_149663916013140.jpg"
root = "D://CateImg//"
baseurl = root + url.split('/')[-1]

print(baseurl)
try:
    if not os.path.exists(root):
        os.makedirs(root)
    r = requests.get(url)
    with open(baseurl, 'wb') as f:
        print("文件正在保存")
        f.write(r.content)
        print("文件保存成功")

except Exception as e:
    print("失败", e)